
package com.joysuch.wwyt.core.enums;

public enum MenuTypes {

    MENU("menu", "菜单"), BUTTON("button", "按钮"), FOLDER("folder", "菜单集合");

    String code;
    String name;

    private MenuTypes(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public boolean is(String code) {
        return this.code.equals(code);
    }

    public static MenuTypes findByCode(String code) {
        if (code == null) {
            return null;
        }
        for (MenuTypes m : MenuTypes.values()) {
            if (m.code.equals(code)) {
                return m;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        MenuTypes m = findByCode(code);
        return m == null ? null : m.getName();
    }
}
